<script setup>
// import { json } from 'express';
import { userCounterStore } from '../stores'
// import { instancelogin } from '../api/modules/user'
import { ref } from "vue"

const useRef = ref()
const pwdRef = ref()


const userstore = userCounterStore()
// userstore.asyncLogin('19191919').then(res => {

//     console.log(res, "[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]");
// }).catch(err => {
//     console.log(err, "-------------------------");
// })
const onLogin = async () => {
    console.log(useRef.value.value, pwdRef.value.value);
    let a = await userstore.asyncLogin(
        {
            "username": useRef.value.value,
            "password": pwdRef.value.value
        }
    )
    // await userstore.settoken('a.data.token')
    console.log(a.data.token);
    // localStorage.setItem('user', a.data.token);
    userstore.settoken(a.data.token)


}
</script>


<template>
    <div class="login">
        <h1>This is login</h1>
        <h1>{{ userstore.token }}</h1>
        账号<input type="text" ref="useRef" value="1111"><br>
        密码: <input type="text" ref="pwdRef">
        <button @click="onLogin()">登录</button>
        <button @click="userstore.removetoken()">退出登录</button>

    </div>
</template>
  
<style></style>